
import 'package:dk_flutter_module_sale/sale/sale_check/room_paint_list/bean/list_config_bean.dart';
import 'package:dk_flutter_base/dk_core.dart';

class MenuItem {
  String title;
  String showType;
  FilterType filterType;
  //MenuItem({this.title,this.showType,this.filterType});

  basicFromJson(Map<String, dynamic> json) {
    this.title = json['title'];
    this.showType = json['showType'];
    switch (showType) {
      case "oneColumn":
        filterType = FilterType.OneColumn;
        break;
      case "calendar":
        filterType = FilterType.Calendar;
        break;
    }
  }
}

class OneColumnSubItem {
  String title;
  String code;
  bool isSelected;
  OneColumnSubItem({this.title,this.code,this.isSelected=false});
  OneColumnSubItem.fromJson(Map<String, dynamic> json) {
    this.title = json['title'];
    this.code = json['code'];
    this.isSelected = false;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['title'] = this.title;
    data['code'] = this.code;
    return data;
  }
}

//单列数据
class OneColumn with MenuItem {
  List<OneColumnSubItem> itemArray;

  FilterType filterType = FilterType.OneColumn;

  OneColumn.fromJson(Map<String, dynamic> json) {
    this.title = json['title'];
    this.showType = json['showType'];
    this.itemArray = (json['itemArray'] as List) != null
        ? (json['itemArray'] as List)
        .map((i) => OneColumnSubItem.fromJson(i))
        .toList()
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['title'] = this.title;
    data['showType'] = this.showType;
    data['itemArray'] = this.itemArray != null
        ? this.itemArray.map((i) => i.toJson()).toList()
        : null;
    return data;
  }
}

//日历数据
class Calendar with MenuItem {
  String selectType;
  String startTime;
  String endTime;
  FilterType filterType = FilterType.Calendar;

  Calendar({
    this.selectType,
    this.startTime,
    this.endTime,
  });

  Calendar.fromJson(Map<String, dynamic> srcJson) {
    basicFromJson(srcJson);
    //this.selectType
    Map filterAction = srcJson["filterAction"];
    selectType = filterAction["selectType"];
    startTime = filterAction["startTime"];
    endTime = filterAction["endTime"];
  }
}

